﻿namespace Pub.Class
{
    using System;
    using System.Web;

    public class Session2
    {
        public static string Get(string key)
        {
            string str = string.Empty;
            string decryptKey = "9cf8d21d394a8919d2f9706dfdc6421e";
            key = (decryptKey + key).MD5();
            if (HttpContext.Current.Session[key].IsNotNull())
            {
                str = Convert.ToString(HttpContext.Current.Session[key]).DESDecode(decryptKey);
            }
            return str;
        }

        public static void Set(string key, string value)
        {
            string encryptKey = "9cf8d21d394a8919d2f9706dfdc6421e";
            key = (encryptKey + key).MD5();
            value = value.DESEncode(encryptKey);
            HttpContext.Current.Session[key] = value;
            if (value.Length == 0)
            {
                HttpContext.Current.Session.Remove(key);
            }
        }
    }
}

